package com.example.composestudy.widget.text

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.composestudy.R

@Preview(showBackground = true)
@Composable
fun TextDemo() {
    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(16.dp)
    ) {
        StringResourceText()
        Divider(modifier = Modifier.padding(vertical = 4.dp), thickness = 1.dp)
        ColorText()
        Divider(modifier = Modifier.padding(vertical = 4.dp), thickness = 1.dp)
    }
}

@Composable
private fun StringResourceText() {
    Text(stringResource(R.string.app_name))
}

@Composable
private fun ColorText() {
    Row {
        Text("Hello World", color = Color.Blue)
        Text(
            "Hello World",
            color = Color(android.graphics.Color.parseColor("#FF0000"))
        )
        Text(
            "Hello World",
            color = Color(red = 0, green = 255, blue = 0)
        )
    }
}
